package com.cloudcc.mobile.dao.impl;

import java.util.List;

import android.text.TextUtils;

import com.cloudcc.cloudframe.net.RequestListener;
import com.cloudcc.cloudframe.net.async.EventRequest;
import com.cloudcc.cloudframe.net.async.JsonObjectRequest;
import com.cloudcc.mobile.dao.BaseEngine;
import com.cloudcc.mobile.dao.ScheduleEngine;
import com.cloudcc.mobile.entity.schedule.ScheduleEntity;
import com.cloudcc.mobile.event.ScheduleEventList.ScheduleInfoEvent;
import com.cloudcc.mobile.event.ScheduleEventList.ScheduleListEvent;
import com.loopj.android.http.RequestParams;

public class ScheduleEngineImpl extends BaseEngine implements ScheduleEngine {

	@Override
	public void getScheduleList(String belongtoid, String year, String month,
			ScheduleListEvent event) {
		EventRequest<List<ScheduleEntity>> request = new EventRequest<List<ScheduleEntity>>() {
		};
		request.setEvent(event);
		RequestParams params = new RequestParams();
		if (!TextUtils.isEmpty(belongtoid)) {
			params.put("belongtoid", belongtoid);
		}
		if (!TextUtils.isEmpty(year)) {
			params.put("year", year);
		}
		if (!TextUtils.isEmpty(month)) {
			params.put("month", month);
		}
		params.put("pageNUM", "0");
		sendPost(params, "getTaskAndEventList", request);
	}

	@Override
	public void getScheduleInfo(String key, ScheduleInfoEvent event) {

	}

	@Override
	public void completeOneTask(String id, RequestListener listener) {
		JsonObjectRequest request = new JsonObjectRequest();
		request.setRequestListener(listener);
		RequestParams params = new RequestParams();
		params.put("id", id);
		sendPost(params, "completeTask", request);
	}

}
